﻿using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using HHControls.CreditEducation.Properties;

namespace HHControls.CreditEducation
{
    public class HHSubForm : Form
    {
        public HHSubForm()
        {
            InitializeForm();
        }

        private void InitializeForm()
        {
            BackColor = Color.White;
            Text = "Credit Education Supporter";
            DoubleBuffered = true;
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            CreateBackgroundImage(e.Graphics, ClientSize.Width, ClientSize.Height);
        }

        private static void CreateBackgroundImage(Graphics g, int width, int height)
        {
            var textureBrush = new TextureBrush(Resources.subform_left, WrapMode.Tile);
            g.FillRectangle(textureBrush, 0, 0, 21, height);

            textureBrush = new TextureBrush(Resources.subform_top, WrapMode.Tile);
            g.FillRectangle(textureBrush, 0, 0, width, 55);

            textureBrush = new TextureBrush(Resources.dot, WrapMode.Tile);
            g.FillRectangle(textureBrush, width - 10, 0, 10, height);
            g.FillRectangle(textureBrush, 0, height - 11, width, 11);

            g.DrawImage(Resources.subform_topleft, 0, 0, 106, 56);
            g.DrawImage(Resources.subform_bottomleft, 0, height - 38, 25, 38);
            g.DrawImage(Resources.subform_bottomright, width - 60, height - 21, 60, 21);
            g.DrawImage(Resources.subform_topright, width - 78, 0, 78, 73);

            //g.DrawImage(Resources.arrow_left, 230, 40, 260, 37);
            //g.DrawImage(Resources.arrow_right, width - 256, 40, 173, 34);
        }

        protected override void OnClientSizeChanged(EventArgs e)
        {
            Invalidate();
            base.OnClientSizeChanged(e);
        }
    }
}